package com.wise.service.portal.content.setting;

import com.wise.entities.content.Setting;
import com.wise.framework.dao.SqlSelect;
import com.wise.framework.daomodel.DaoList;
import com.wise.summer.v1.portal.content.setting.GetSetting;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

import java.util.List;

/**
 * @author Pitaya
 * @date 2019-11-14
 */

@Service
@SummerService
public class GetSettingService implements SummerServiceBean<GetSetting> {
    private static final String NAME = "webset";

    @Override
    public void sum(GetSetting summer) {
        if (StringUtils.isEmpty(summer.getName())) {
            summer.setName(NAME);
        }
        SqlSelect selectSetting = SqlSelect.selec("*")
                .fromClassName(Setting.class)
                .eqLang(Setting._lang)
                .eq(Setting._name, summer.getName());
        List<Setting> infoList = DaoList.s(Setting.class, selectSetting);
        if (infoList.size() > 0) {
            summer.setSummerResult(infoList.get(0).getInfo());
        }
    }
}
